package org.keshproject.dms.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.keshproject.dms.dao.IBalanceSheetDao;
import org.keshproject.dms.pojo.BalanceSheet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class BalanceSheetDao extends GenericDao<BalanceSheet, Integer>
		implements IBalanceSheetDao {
	@Autowired
	public BalanceSheetDao(SessionFactory sessionFactory) {
		setSessionFactory(sessionFactory);
	}

	public BalanceSheet getByFiscalYear(int companyId, int fiscalYear) {
		Object[] params = new Object[] { companyId, fiscalYear };
		List<BalanceSheet> list = (List<BalanceSheet>) getHibernateTemplate()
				.find("from BalanceSheet as c where c.companyInfo.id=? and c.fiscalYear=?",
						params);
		if (list != null && list.size() >= 1) {
			return list.get(0);
		}
		return null;
	}
}
